<@html>
<link rel="stylesheet" href="${path!}/js/dojo/dojox/grid/resources/${theme!}Grid.css">
<script type="text/javascript" src="${path}/js/dojo/dojo/inputForm.gzjs"></script>
<script type="text/javascript" src="${path}/js/dojo/dojo/naviGrid.gzjs"></script>
<script type="text/javascript">
	//dojo.require("dijit.dijit");
	//dojo.require("dijit.form.Form");
	//dojo.require("dijit.form.Button");
	//dojo.require("dojox.data.QueryReadStore");
	//dojo.require("widget.navgrid.NavGrid");
	//dojo.require("dijit.form.NumberTextBox");
	//dojo.require("dijit.form.ValidationTextBox");
</script>
<@queryForm>
<table>
	<tr>
		<td>
		<@s.text name="noteType"/>：
		</td>
		<td>
			<input id="noteType" name="snSetup.noteType" dojoType="dijit.form.ValidationTextBox" promptMessage="单据类型"/>
		</td>
		<td>
		<@s.text name="noteName"/>：
		</td>
		<td>
			<input id="noteName" name="snSetup.noteName" dojoType="dijit.form.ValidationTextBox" promptMessage="单据名称"/>
		</td>
		<td>
		<@s.text name="dateFmt"/>：
		</td>
		<td>
			<input id="dateFmt" name="snSetup.dateFmt" dojoType="dijit.form.ValidationTextBox"
			       promptMessage="时间格式化字符串"/>
		</td>
	</tr>
	<tr>
		<td>
		<@s.text name="notePrefix"/>：
		</td>
		<td>
			<input id="notePrefix" name="snSetup.notePrefix" dojoType="dijit.form.ValidationTextBox"
			       promptMessage="单据前缀"/>
		</td>
		<td>
		<@s.text name="growStep"/>：
		</td>
		<td>
			<input id="growStep" name="snSetup.growStep" dojoType="dijit.form.NumberTextBox" promptMessage="递增步伐"/>
		</td>
		<td>
		<@s.text name="snLength"/>：
		</td>
		<td>
			<input id="snLength" name="snSetup.snLength" dojoType="dijit.form.NumberTextBox" promptMessage="流水号长度"/>
		</td>
	</tr>
	<tr>
		<td>
		<@s.text name="leftPadChar"/>：
		</td>
		<td>
			<input id="leftPadChar" name="snSetup.leftPadChar" dojoType="dijit.form.ValidationTextBox"
			       promptMessage="左边补齐字符"/>
		</td>
	</tr>
</table>
</@queryForm>
<@toolbar/>
<table jsId="grid" id="grid" dojoType="widget.navgrid.NavGrid"
       selectionMode="single" rowsPerPage="10"
       structure="layout" autoHeight="true">
</table>
</@html>
<script language="javascript" type="text/javascript">
	var store = new dojox.data.QueryReadStore({
				url : "${path!}/system/snsetup.list.do",
				requestMethod : "post"
			});
	var layout = [
		{
		},
		{
			cells : [
				[
					{
						name : "<@s.text name="noteType"/>",
						field : "noteType",
						width:"14%",
						headerClasses:"gridHeader"
					}            ,
					{
						name : "<@s.text name="noteName"/>",
						field : "noteName",
						width:"14%",
						headerClasses:"gridHeader"
					}            ,
					{
						name : "<@s.text name="dateFmt"/>",
						field : "dateFmt",
						width:"14%",
						headerClasses:"gridHeader"
					}            ,
					{
						name : "<@s.text name="notePrefix"/>",
						field : "notePrefix",
						width:"14%",
						headerClasses:"gridHeader"
					}            ,
					{
						name : "<@s.text name="growStep"/>",
						field : "growStep",
						width:"14%",
						headerClasses:"gridHeader"
					}            ,
					{
						name : "<@s.text name="snLength"/>",
						field : "snLength",
						width:"14%",
						headerClasses:"gridHeader"
					}            ,
					{
						name : "<@s.text name="leftPadChar"/>",
						field : "leftPadChar",
						width:"14%",
						headerClasses:"gridHeader"
					}
				]
			]
		}
	];
	dojo.ready(function() {
		//事件注册
		//新增
		dojo.subscribe('btnAdd.click', null, function() {
			parent.openDialog({
						id:"snsetup/add",
						url:"${path!}/system/snsetup.load.do?processType=add",
						title:"新增"
					});
		})
		//编辑
		dojo.subscribe('btnEdit.click', null, function() {
			var id = store.getValue(grid.selection.getSelected()[0], "id");
			parent.openDialog({
						id: "snsetup/update",
						url : "${path!}/system/snsetup.load.do?processType=update&snSetup.id=" + id,
						title : "修改",
						width : 800,
						height : 600
					});
		})
		//查看
		grid.onRowDblClick = function (e) {
			if (e.rowIndex > -1) {
				var item = grid.getItem(e.rowIndex);
				if (store.isItem(item)) {
					var id = store.getIdentity(item);
					parent.openDialog({
								id: "snsetup/View",
								url : "${path!}/system/snsetup.load.do?processType=view&snSetup.id=" + id,
								title : "查看",
								width : 800,
								height : 600
							})
				}
			}
		}
		//删除
		dojo.subscribe('btnDelete.click', function() {
			if (!grid.selection.getSelected() || grid.selection.getSelected().length == 0) {
				window.parent.Error("您未选择数据！");
				return;
			}
			var id = store.getValue(grid.selection.getSelected()[0], "id");
			parent.Confirm({
						msg : "确认删除数据吗？",
						okCall : function() {
							dojo.xhrGet({
										url:"${path!}/system/snsetup.delete.do?snSetup.id=" + id,
										handleAs:"json",
										load:function(json) {
											window.parent.Info("删除成功！", function() {
												grid.reload();
											});
										}
									})
						}
					})
		})
		//查询
		dojo.subscribe('btnQuery.click', null, function() {
			grid.setStore(store, dojo.formToObject(dojo.byId('queryForm')));
		})
		//注册响应函数
		parent.subscribe("${pageId!}", "snsetup/refresh", null, function() {
			grid.reload();
		})
	})
</script>
